﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Upload.aspx.cs" Inherits="BuXiaChu.OrderDishes.Web.Admin.Upload" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title></title>
    <link media="screen, projection" rel="stylesheet" type="text/css" href="/css/swfupload.css" />

    <script type="text/javascript" src="/js/Extend.js"></script>

    <script type="text/javascript" src="/js/Common.js"></script>

    <script type="text/javascript" src="js/swfupload/swfupload.js"></script>

    <script type="text/javascript" src="/js/jquery-vsdoc.js"></script>

    <%--<script type="text/javascript" src="js/swfupload/fileprogress.js"></script>--%>
    <%--<script type="text/javascript" src="js/swfupload/handlers.js"></script>--%>

    <script type="text/javascript" src="js/swfupload/swfupload.queue.js"></script>

</head>
<body>
    <form id="form1" runat="server" enctype="multipart/form-data">
    <div>
        <asp:FileUpload ID="FileUpload1" runat="server" />
        <asp:Button ID="Button1" runat="server" Text="Button" />
        <div class="" id="fsUploadProgress">
            <span class="legend">Upload Queue</span>
        </div>
        <div id="divStatus">
            0 Files Uploaded</div>
        <div>
            <span id="spanButtonPlaceHolder"></span>
            <input id="btnCancel" type="button" value="Cancel All Uploads" onclick="cancelAllUpload()"
                disabled="disabled" style="margin-left: 2px; font-size: 8pt; height: 29px;" />
        </div>
    </div>
    </form>
</body>
</html>

<script type="text/javascript">
    //upload flash handler  call
    function fileDialogComplete(numFilesSelected, numFilesQueued, numFilesInQueue) {
        try {
            if (numFilesSelected > 0) {
                document.getElementById(this.customSettings.cancelButtonId).disabled = false;
            }
            this.startUpload();
        } catch (ex) {
            this.debug(ex);
        }
    }
    function fileQueued(file) {
        try {
            var progress = new UploadProcessor(file, this.customSettings.progressTarget);
            progress.progress("等待上传");

        } catch (ex) {
            this.debug(ex);
        }
    }
    function uploadStart(file) {
        try {//判断文件类型
            if (file.index == 1) {
                this.cancelUpload(file.id);
                this.uploadError(file, -11, "文件类型错误");
                this.uploadComplete(file);
                return false;
            }
        } catch (ex) {
            this.debug(ex);
        }
        return true;
    }
    function uploadProgress(file, bytesComplete, bytesTotal) {
        try {
            var percent = Math.ceil((bytesComplete / bytesTotal) * 100);
            var processor = new UploadProcessor(file, this.customSettings.progressTarget);
            processor.progress(percent);
        } catch (ex) {
            this.debug(ex);
        }
    }
    function uploadSuccess(file, serverData, responseReceived) {
        try {
            var processor = new UploadProcessor(file, this.customSettings.progressTarget);
            processor.progress("上传成功");
        } catch (ex) {
            this.debug(ex);
        }
    }
    function uploadError(file, errorCode, message) {
        var progress = new UploadProcessor(file, this.customSettings.progressTarget);
        progress.progress(message);
    }

    function uploadComplete(file) {
        if (this.getStats().files_queued === 0) {
            document.getElementById(this.customSettings.cancelButtonId).disabled = true;
        }

    }

    function cancelAllUploads() {
        swfu.cancelQueue();
    }

    //上传进度显示
    function UploadProcessor(file, containerId) {
        this.id = "div_UploadProcessor_" + file.index;
        this.currentUploadedId = file.id;
        this.container = jDoc(containerId);
        this.currentElem = jDoc(this.id);
        if (!this.currentElem) {
            this.currentElem = document.createElement("div");
            this.currentElem.id = this.id;
            this.container.appendChild(this.currentElem);
        }
    }

    UploadProcessor.prototype.progress = function(percent) {
        this.currentElem.innerHTML = percent;
    }
</script>

<script type="text/javascript">
    var swfu;

    window.onload = function() {
        var settings = {
            flash_url: "/js/swfupload/swfupload.swf",
            upload_url: "upload.ashx",
            post_params: { "PHPSESSID": "" },
            file_size_limit: "0 MB",
            file_types: "*.*",
            file_types_description: "All Files",
            file_upload_limit: 0,
            file_queue_limit: 0,
            custom_settings: {
                progressTarget: "fsUploadProgress",
                cancelButtonId: "btnCancel"
            },
            debug: true,

            // Button settings
            button_image_url: "images/TestImageNoText_65x29.png",
            button_width: "65",
            button_height: "29",
            button_placeholder_id: "spanButtonPlaceHolder",
            button_text: '<span class="theFont">Hello</span>',
            button_text_style: ".theFont { font-size: 16; }",
            button_text_left_padding: 12,
            button_text_top_padding: 3,

            file_queued_handler: fileQueued,
            //file_queue_error_handler: fileQueueError,
            file_dialog_complete_handler: fileDialogComplete,
            upload_start_handler: uploadStart,
            upload_progress_handler: uploadProgress,
            upload_error_handler: uploadError,
            upload_success_handler: uploadSuccess,
            upload_complete_handler: uploadComplete,
            //queue_complete_handler: queueComplete	// Queue plugin event
        };

        swfu = new SWFUpload(settings);
    };    
</script>

<script type="text/javascript">
    
</script>

